<template>
  <div class="shopcart">
    <navbar class="cartnav">
      <template #tab-center>
        <div>
          购物车<span v-if="length > 0">({{ length }})</span>
        </div>
      </template>
    </navbar>
    <cartlist :cartlist="cart" />
    <!-- <cartrecommend /> -->
    <cartBottomBar />
  </div>
</template>

<script>
import navbar from "@/components/common/nav-tab/nav-tab";
import cartlist from "./Children/Cart-list";
import cartBottomBar from "./Children/CartBottomBar";
import cartrecommend from "./Children/recommend";
import { mapGetters } from "vuex";
export default {
  name: "shopcart",
  components: {
    navbar,
    cartlist,
    cartrecommend,
    cartBottomBar,
  },
  computed: {
    //将vuex中getters转换成计算属性  ，名字默认为getters中的名字
    // ...mapGetters(["cartlength"]),
    ...mapGetters({
      length: "cartlength", //改成自己想用的名字
      cart: "getcart",
    }),
  },
  mounted() {
    // console.log(this.$store.getters.getcart);
  },
  methods: {},
};
</script>

<style scoped>
.shopcart {
  height: calc(100vh - 130px);
  background-color: gainsboro;
}
.cartnav {
  color: #fff;
  font-size: 20px;
}
</style>